package com.example.enjoylearning.login

import android.content.Context
import com.example.enjoylearning.model.LoginBen

/**
 * @Author ninetailedfox
 * @Data 2022/10/31 10:17 下午
 * @ClassName LoginPresenterImpl
 **/
class LoginPresenterImpl(private val loginView: LoginView) : LoginPresenter, LoginPresenter.OnLoginListener,
    LoginPresenter.OnRegisterListener {

    var loginModuleImpl = LoginModuleImpl()

    override fun loginWanAndroid(context: Context, username: String, password: String) {
        loginModuleImpl.login(context, username, password, this)
    }

    override fun registerWanAndroid(
        context: Context,
        username: String,
        password: String,
        repassword: String
    ) {
        loginModuleImpl.register(context, username, password, repassword, this)
    }

    override fun loginSuccess(loginBen: LoginBen) {
        loginView.onLoginSuccess(loginBen)
    }

    override fun loginFailed(message: String) {
        loginView.onLoginFail(message)
    }

    override fun registerSuccess(loginBen: LoginBen) {
        loginView.onRegisterSuccess(loginBen)
    }

    override fun registerFailed(message: String) {
        loginView.onRegisterFail(message)
    }
}